// 1.引入异步对象
import request from '@/utils/request'
import type { AttrInfoModelList } from './model/attrModel'
import type {CategoryStoreId} from './model/categoryModel'
// 2.使用枚举存储接口地址
enum Api{
  getAttrListApi = '/admin/product/attrInfoList',
  getAttrOneDelete = '/admin/product/deleteAttr',
  getAddAttrValue = '/admin/product/saveAttrInfo'
}
// 3.书写接口函数
// 3.1请求属性列表
export const reqGetAttrListDataByCategory3Id = ({category1Id, category2Id, category3Id}:CategoryStoreId) => {
  return request.get<any, AttrInfoModelList[]>(`${ Api.getAttrListApi}/${category1Id}/${category2Id}/${category3Id}`)
}

// 3.2.删除列表数据
export const reqDeleteOneAttr = (id:number) => {
  return request.delete<any,null>(`${Api.getAttrOneDelete}/${id}`)
}

// 3.3增加或更新属性
export const reqAddAttrValue = (attrInfo:AttrInfoModelList) => {
  return request.post<any,null>(`${Api.getAddAttrValue}`,attrInfo)
}